package com.we.connect.weconnect.config;

import com.we.connect.weconnect.utils.UserUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object o = UserUtils.getSysUser(request, "loginSysUser");
        if(null == o){
            response.sendRedirect("/login");
            return false;
        }
        return true;
    }
}
